package com.yyoa.testData;

import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;

import org.junit.Test;

import com.yyoa.entity.User;
import com.yyoa.util.HexUtil;

public class UserDaoTestData extends BaseDaoTest {

	@Test
	public void addUser() {
		User user = createUserInstance("admin", "email@email.com", "男", 123);
	}

	private User createUserInstance(String userName, String email, String sex,
			long mobilePhone) {
		User user = new User();
		user.setUserName(userName);
		try {
			user.setPassword(HexUtil.getEncryptedPwd("111"));
		} catch (NoSuchAlgorithmException | UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		user.setEmail(email);
		user.setMobilePhone(mobilePhone);
		user.setSex(sex);
		userDao.saveOrUpdate(user);
		return user;
	}

}
